file_mounts:
  # Mounting public buckets for AWS
  {% if include_s3_mount | default(True) %}
  /mount_public_s3:
    source: s3://digitalcorpora
    mode: MOUNT
  {% endif %}

  # Mounting public buckets for GCP
  {% if include_gcs_mount | default(True) %}
  /mount_public_gcp:
    source: gs://gcp-public-data-sentinel-2
    mode: MOUNT
  {% endif %}

  {% if include_azure_mount | default(True) %}
  # Mounting public buckets for Azure
  /mount_public_azure:
    source: https://azureopendatastorage.blob.core.windows.net/nyctlc
    mode: MOUNT

  # Multiple mount points for Azure
  /mount_public_azure_2:
    source: https://azureopendatastorage.blob.core.windows.net/nyctlc
    mode: MOUNT
  {% endif %}

  # Mounting private buckets in COPY mode with a source dir
  /mount_private_copy:
    name: {{storage_name}}
    source: ~/tmp-workdir
    mode: {% if only_mount | default(false) %}MOUNT{% else %}COPY{% endif %}
    {% if store_type is defined %}store: {{store_type}}{% endif %}

  # Mounting private buckets in COPY mode with a list of files as source
  /mount_private_copy_lof:
    name: {{storage_name}}
    source: ['~/tmp-workdir/tmp file', '~/tmp-workdir/tmp file2']
    mode: {% if only_mount | default(false) %}MOUNT{% else %}COPY{% endif %}
    {% if store_type is defined %}store: {{store_type}}{% endif %}

  # Mounting private buckets in MOUNT mode
  /mount_private_mount:
    name: {{storage_name}}
    source: ~/tmp-workdir
    mode: MOUNT
    {% if store_type is defined %}store: {{store_type}}{% endif %}

  # Mounting private buckets in MOUNT_CACHED mode
  {% if include_mount_cached | default(False) %}
  /mount_private_mount_cached:
    name: {{storage_name}}
    source: ~/tmp-workdir
    mode: MOUNT_CACHED
    {% if store_type is defined %}store: {{store_type}}{% endif %}
  {% endif %}

  # Mounting empty workdir
  /mount_empty_workdir:
    name: {{empty_storage_name}}
    source: ~/empty-workdir
    mode: MOUNT
    {% if store_type is defined %}store: {{store_type}}{% endif %}

run: |
  set -ex

  # Check public bucket contents
  {% if include_s3_mount | default(True) %}
  ls -ltr /mount_public_s3/corpora
  {% endif %}
  {% if include_gcs_mount | default(True) %}
  ls -ltr /mount_public_gcp/tiles
  {% endif %}
  {% if include_azure_mount | default(True) %}
  ls -ltr /mount_public_azure/green
  ls -ltr /mount_public_azure_2/green
  {% endif %}

  # Check private bucket contents
  ls -ltr /mount_private_copy/foo
  ls -ltr /mount_private_copy/tmp\ file
  ls -ltr /mount_private_copy_lof/tmp\ file
  ls -ltr /mount_private_copy_lof/tmp\ file2
  ls -ltr /mount_private_mount/foo
  ls -ltr /mount_private_mount/tmp\ file

  # Symlinks are not copied to buckets
  ! ls /mount_private_copy/circle-link
  ! ls /mount_private_mount/circle-link

  # Write to private bucket in MOUNT mode should pass
  echo "hello" > /mount_private_mount/hello.txt

  {% if include_mount_cached | default(False) %}
  # Check private bucket contents
  ls -ltr /mount_private_mount_cached/foo
  ls -ltr /mount_private_mount_cached/tmp\ file

  # Symlinks are not copied to buckets
  ! ls /mount_private_mount_cached/circle-link

  # Write to private bucket in MOUNT_CACHED mode should pass
  echo "hello" > /mount_private_mount_cached/hello.txt
  {% endif %}
